package uscdb.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;

@Entity
@Table(name = "tproduct")
@DynamicInsert(true)
@DynamicUpdate(true)
@Indexed
@Analyzer(impl = org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer.class)
public class Tproduct implements java.io.Serializable {

	private static final long serialVersionUID = 258578830843196642L;
	private String id;
	private String name;
	private String description;
	private Set<Tversion> tversionSet = new HashSet<Tversion>();

	@Id
	@Column(name = "ID", unique = true, nullable = false, length = 36)
	@DocumentId
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "name")
	@Field(store = Store.YES) // 表示存储索引
//	@FieldBridge(impl = ClobFieldBridge.class)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "tproduct")
	public Set<Tversion> getTversionSet() {
		return tversionSet;
	}

	public void setTversionSet(Set<Tversion> tversionSet) {
		this.tversionSet = tversionSet;
	}
	
	@Column(name = "description", length = 1000)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

}
